﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RailroadDal;
using RauteAdministarion.ViewModels;

namespace RauteAdministarion.Views
{
    /// <summary>
    /// Interaction logic for RauteAdministration.xaml
    /// </summary>
    public partial class RauteAdministration : UserControl
    {
        public RauteAdministration()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Station station = new Station();
            station.StationName = tbStationName.Text;
            station.OffsetX = int.Parse(tbOfsetX.Text);
            station.OffsetY= int.Parse(tbOfsetY.Text);
            var viewModel = (this.DataContext as ViewModelRailroads);
            viewModel.AddStation.Execute(station);
        }

        private void Button_UpdateStation(object sender, RoutedEventArgs e)
        {
            var viewModel = (this.DataContext as ViewModelRailroads);
            Station station = viewModel.SelectedStation;
            station.StationName = tbUpdateName.Text;
            station.OffsetX = int.Parse(tbUpdateOffsetX.Text);
            station.OffsetY = int.Parse(tbUpdateOffsetY.Text);
            viewModel.UpdateStation.Execute(station);
        }

        private void Button_Click_DeleteStation(object sender, RoutedEventArgs e)
        {
            var viewModel = (this.DataContext as ViewModelRailroads);
            Station station = viewModel.SelectedStation;
            viewModel.DeleteStation.Execute(station.StationId);
        }

        private void Button_DeleteDistance(object sender, RoutedEventArgs e)
        {

        }
    }
}
